package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductFavorites;
import com.nbsaas.boot.product.api.domain.simple.ProductFavoritesSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 产品收藏-列表对象转换器
*/

public class ProductFavoritesSimpleConvert implements Converter<ProductFavoritesSimple, ProductFavorites> {




@Override
public ProductFavoritesSimple convert(ProductFavorites source) {
    ProductFavoritesSimple result = new ProductFavoritesSimple();


               try {
                   if(source.getProduct()!=null){
                       result.setProduct(source.getProduct().getId());
                   }
                } catch (Exception ignored) { }


               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }


               try {
                   if(source.getShop()!=null){
                       result.setShop(source.getShop().getId());
                   }
                } catch (Exception ignored) { }


                try {
                    if(source.getShop()!=null){
                        result.setShopName(source.getShop().getName());
                    }
                } catch (Exception ignored) { }

                if(source.getProduct()!=null){
                    result.setProductLogo(source.getProduct().getLogo());
                }
                result.setId(source.getId());
                result.setAddDate(source.getAddDate());
                result.setLastDate(source.getLastDate());


    return result;
}

}